package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.TIcbcNanpingReferrer;
import com.freesky.biz.icbc.domain.TIcbcNanpingReferrerCoupon;
import com.freesky.biz.icbc.service.INanpingPartnerService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 南平工银社区节合伙人
 */
@RestController
@RequestMapping("/icbc/nanping/partner")
public class NanpingPartnerController extends BaseController {

    @Autowired
    private INanpingPartnerService nanpingPartnerService;


    @PreAuthorize("@ss.hasPermi('icbc:nanping:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIcbcNanpingReferrer financeReferrer) {
        startPage();
        List<TIcbcNanpingReferrer> list = nanpingPartnerService.findList(financeReferrer);
        return getDataTable(list);
    }

    @Log(title = "南平工银社区节", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:nanping:export')")
    @GetMapping("/export")
    public AjaxResult export(TIcbcNanpingReferrer financeReferrer,
                             HttpServletResponse response) {
        return nanpingPartnerService.exportFile(financeReferrer);
    }

    @PreAuthorize("@ss.hasPermi('icbc:nanping:list')")
    @GetMapping("/listCoupon")
    public TableDataInfo listCoupon(TIcbcNanpingReferrerCoupon referrerCoupon) {
        startPage();
        List<TIcbcNanpingReferrerCoupon> list = nanpingPartnerService.findReferrerCouponList(referrerCoupon);
        return getDataTable(list);
    }

    @Log(title = "南平工银社区节", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:nanping:export')")
    @GetMapping("/exportCoupon")
    public AjaxResult exportCoupon(TIcbcNanpingReferrerCoupon referrerCoupon,
                             HttpServletResponse response) {
        return nanpingPartnerService.exportCouponFile(referrerCoupon);
    }
}
